package com.zznode.redsun.commons.dto;

import org.springframework.util.StringUtils;

import com.zznode.csp.domain.commons.util.MapCreaterBuilder;

public class RecordQuery {
	private String customerName;

	private String productName;

	private String title;

	public String buildSql(String querySql, MapCreaterBuilder parameters) {
		StringBuilder builder = new StringBuilder(querySql);
		if (StringUtils.hasText(title)) {
			builder.append(" and t1.title like :title");
			parameters.put("title", "%" + title + "%");
		}
		if (StringUtils.hasText(customerName)) {
			builder.append(" and t2.name like :customerName");
			parameters.put("customerName", "%" + customerName + "%");
		}
		if (StringUtils.hasText(productName)) {
			builder.append(" and t3.name like :productName");
			parameters.put("productName", "%" + productName + "%");
		}
		return builder.toString();
	}

	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
}
